<?php

namespace App\Containers\AppSection\BankDetail\Actions;

use App\Containers\AppSection\BankDetail\Models\BankDetail;
use App\Containers\AppSection\BankDetail\Tasks\ChangeMasterAccountTask;
use App\Containers\AppSection\BankDetail\UI\API\Requests\ChangeMasterAccountRequest;
use App\Containers\AppSection\Log\Tasks\CreateLogTask;
use App\Ship\Parents\Actions\Action;

class ChangeMasterAccountAction extends Action
{
    public function run(int $id, ChangeMasterAccountRequest $request): BankDetail
    {
        $masterAccount = app(ChangeMasterAccountTask::class)->run($id);

        app(CreateLogTask::class)->run($request->profile()->id, "Банковские реквизиты №{$masterAccount->id} сделаны основными", 'bankDetail');

        return $masterAccount;
    }
}
